<template>
    <div id="hospital" class="hospital">
        <el-table :data="dataList.slice((currentPage-1)*pagesize,currentPage*pagesize)" stripe border
                  :height="tableHeight" :header-cell-style="getRowClass">
            <el-table-column fixed type="index" label="*" sortable min-width="40"></el-table-column>
            <el-table-column prop="applyDealerName" label="报单经销商" sortable min-width="250"></el-table-column>
            <el-table-column prop="applyHospitalName" label="医院名称" sortable min-width="250"></el-table-column>
            <el-table-column prop="applyOfficeName" label="报单科室" sortable min-width="140"></el-table-column>
            <el-table-column prop="applyStatusDesc" label="审核结果" sortable min-width="130"></el-table-column>
            <el-table-column fixed="right" label="操作" sortable align="center" width="75">
                <template slot-scope="scope">
                    <el-button @click="updateList(scope.row)" type="text" size="mini">审核</el-button>
                </template>
            </el-table-column>
        </el-table>
        <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange"
                       :current-page="currentPage" :page-sizes="[5,10, 15,20, 25,30,50, 100]" :page-size="pagesize"
                       layout="total, sizes, prev, pager, next, jumper" :total="dataList.length"></el-pagination>

        <!-- 详情框 -->
        <el-dialog :title="dialogTitle" width="75%" top="60px" :visible.sync="isDialog" :close-on-click-modal="false" style="padding-bottom: 15px;">
            <el-tabs v-model="activeName" @tab-click="handleClick" style="padding-bottom: 15px;">
                <el-tab-pane label="基本信息" name="1" :style="dialogHeight">
                    <h3 class="dialog-plate-title"><span>医院基本信息</span></h3>
                    <el-form :inline="true" class="demo-form-inline" label-position="right" label-width="120px"
                             :model="dialogDetailList">
                        <el-form-item label="医院名称">
                            <el-input v-model="dialogDetailList.applyHospitalName" :disabled="isState"></el-input>
                        </el-form-item>
                        <el-form-item label="医院类别">
                            <el-select v-model="dialogDetailList.applyHospitalType" :disabled="isState">
                                <el-option v-for="item in hospitalCategory" :key="item.id" :value="item.id"
                                           :label="item.name"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="医院级别">
                            <el-select v-model="dialogDetailList.applyHospitalLevel" :disabled="isState">
                                <el-option v-for="item in hospitalLevel" :key="item.code" :value="item.code" :label="item.name"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-form>
                    <el-form :inline="true" class="demo-form-inline" label-position="right" label-width="120px"
                             :model="dialogList">
                        <el-form-item label="医院地址">
                            <div style="width: 610px;">
                                <el-select v-model="sheng" @change="choseSheng(sheng,1)" :disabled="isState" placeholder="省级地区">
                                    <el-option v-for="item in shengs" :key="item.value" :label="item.value"
                                               :value="item.value"></el-option>
                                </el-select>
                                <el-select v-model="shi" @change="choseCity(shi,1)" :disabled="isState" placeholder="市级地区">
                                    <el-option v-for="item in shis" :key="item.value" :label="item.value"
                                               :value="item.value"></el-option>
                                </el-select>
                                <el-select v-model="qu" @change="choseBlock(qu,1)" :disabled="isState" placeholder="区级地区">
                                    <el-option v-for="item in qus" :key="item.value" :label="item.value"
                                               :value="item.value"></el-option>
                                </el-select>
                                <el-input v-model="dialogDetailList.applyAddressDetail" :disabled="isState" style="margin-top: 5px;" type="textarea" :rows="2" placeholder="请输入详细地址"></el-input>
                            </div>
                        </el-form-item>
                    </el-form>
                    <el-form :inline="true" class="demo-form-inline" label-position="right" label-width="120px" :model="dialogDetailList">
                        <el-form-item label="申请单位"><el-input v-model="dialogDetailList.applyDealerName" disabled></el-input></el-form-item>
                        <el-form-item label="申请人"><el-input v-model="dialogDetailList.applyDealerUserName" disabled></el-input></el-form-item>
                        <el-form-item label="申请时间"><el-date-picker v-model="dialogDetailList.applyTime" type="datetime" disabled placeholder="选择日期时间"  style="width: 200px;"></el-date-picker></el-form-item>
                        <el-form-item label="报单科室"><el-input v-model="dialogDetailList.applyOfficeName" disabled></el-input></el-form-item>
                    </el-form>
                    <el-form label-position="right" label-width="120px" :model="dialogDetailList">
                        <el-form-item label="申请原因"><el-input v-model="dialogDetailList.applyReason" disabled type="textarea" :row="8" style="width: 96%;"></el-input></el-form-item>
                    </el-form>
                    <div style="text-align: right;" v-if="!isState">
                        <el-button @click="submitList" type="primary" style="margin-right: 1%;">确定医院信息</el-button>
                    </div>

                    <h3 class="dialog-plate-title" v-if="isState"  ><span>审核</span></h3>
                    <el-form  v-if="isState"  :inline="true" class="demo-form-inline" label-position="right" label-width="120px" :model="dialogDetailList">
                        <el-form-item label="审核结果"><el-select v-model="dialogDetailList.applyStatus" :disabled="isToExamine"><el-option :value="1" label="审核通过"></el-option><el-option :value="2" label="审核不通过"></el-option></el-select></el-form-item>
                        <el-form-item label="审核人"><el-input v-model="dialogDetailList.auditUserIdName" disabled></el-input></el-form-item>
                        <el-form-item label="审核时间"><el-date-picker v-model="dialogDetailList.applyTime"  disabled type="datetime" :disabled="true" placeholder="选择日期时间" style="width: 200px;"></el-date-picker></el-form-item>
                    </el-form>
                    <el-form v-if="isState"  label-position="right" label-width="120px" :model="dialogDetailList">
                        <el-form-item label="审核意见"><el-input v-model="dialogDetailList.auditDetail" :disabled="isToExamine" type="textarea" :rows="5" style="width: 95%;"></el-input></el-form-item>
                    </el-form>
                    <div style="text-align: right;" v-if="isState">
                        <el-button @click="isSubmitToExamineList" :disabled="isToExamine" type="primary" style="margin-right: 1%;">提交审核</el-button>
                    </div>
                </el-tab-pane>
                <el-tab-pane label="地图统计" name="2" :style="dialogHeight">
                    <!-- 地图 -->
                    <div style="margin-bottom: 10px;">
                        <span @click="toggleVisible('0')" style="height: 40px;margin-right: 20px;cursor:pointer;"><img ref="icon0" src="../../../../static/img/icon02.png" alt="" style="width: 30px;height: 20px;">  未报单</span>
                        <span @click="toggleVisible('1')" style="height: 40px;margin-right: 20px;cursor:pointer;"><img ref="icon1" src="../../../../static/img/icon01.png" alt="" style="width: 30px;height: 20px;">已报单</span>
                        <span @click="toggleVisible('2')" style="height: 40px;margin-right: 20px;cursor:pointer;"><img ref="icon2" src="../../../../static/img/icon05.png" alt="" style="width: 30px;height: 20px;">当前报单医院</span>
                    </div>
                    <div class="amap-page-container" >
                        <el-amap vid="amapDemo" :plugin="plugin" :center="center" :zoom="zoom" class="amap-demo">
                            <el-amap-marker v-for="marker in markers" :key="markers.applyStatus" :position="marker.position" :icon="marker.icon" :animation="marker.animation" :visible="marker.visible" :events="marker.events"></el-amap-marker>
                            <el-amap-info-window v-if="false" :position="window.position" :visible="window.content" :template="window.content" ></el-amap-info-window>
                        </el-amap>
                    </div>
                </el-tab-pane>
                <el-tab-pane label="医院已报单科室" name="3" :style="dialogHeight"  v-if="isState" >
                    <!-- 报单详情 -->
                    <el-table :data="hospitalDetailData.slice((currentPage-1)*pagesize,currentPage*pagesize)" stripe border :height="tableHeight-150" :header-cell-style="getRowClass">
                        <el-table-column fixed type="index" label="*" sortable min-width="40"></el-table-column>
                        <el-table-column prop="applyOfficeName" label="科室" sortable min-width="120"></el-table-column>
                        <el-table-column prop="applyDealerName" label="报单经销商" sortable min-width="250"></el-table-column>
                        <el-table-column prop="applyTime" label="报单时间" :formatter="formatTimestampToTime" sortable min-width="170"></el-table-column>
                        <el-table-column prop="applyStatusDesc" label="审核结果" sortable min-width="110"></el-table-column>
                        <el-table-column prop="auditUserName" label="审核人" sortable min-width="100"></el-table-column>
                        <el-table-column prop="auditTime" label="审核时间" :formatter="formatTimestampToTime" sortable min-width="170"></el-table-column>
                    </el-table>
                    <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage" :page-sizes="[5,10, 15,20, 25,30,50, 100]" :page-size="pagesize" layout="total, sizes, prev, pager, next, jumper" :total="hospitalDetailData.length"></el-pagination>
                </el-tab-pane>

            </el-tabs>
        </el-dialog>


        <!-- 医院报单详情 -->
        <el-dialog title="医院报单详情" width="980px" center :visible.sync="isHospitalDetailDialog" :close-on-click-modal="false" style="padding-bottom: 15px;">
            <el-form :inline="true" class="demo-form-inline" label-position="right" label-width="120px" :model="dialogHospitalDetailList">
                <el-form-item label="医院名称"><el-input v-model="dialogHospitalDetailList.hospitalName"></el-input></el-form-item>
                <el-form-item label="医院类别"><el-select v-model="dialogHospitalDetailList.hospitalType"><el-option v-for="item in hospitalCategory" :key="item.id" :value="item.id"
                                                                                                                 :label="item.name"></el-option></el-select></el-form-item>
                <el-form-item label="医院级别"><el-select v-model="dialogHospitalDetailList.hospitalLevel"><el-option v-for="item in hospitalLevel" :key="item.code" :value="item.code" :label="item.name"></el-option></el-select></el-form-item>
            </el-form>
            <el-form :inline="true" class="demo-form-inline" label-position="right" label-width="120px" :model="dialogList">
                <el-form-item label="医院地址">
                    <div style="width: 610px;">
                        <el-select v-model="sheng1" @change="choseSheng(sheng1,1)" placeholder="省级地区"><el-option v-for="item in shengs" :key="item.value" :label="item.value" :value="item.value"></el-option></el-select>
                        <el-select v-model="shi1" @change="choseCity(shi1,1)" placeholder="市级地区"><el-option v-for="item in shis" :key="item.value" :label="item.value" :value="item.value"></el-option></el-select>
                        <el-select v-model="qu1" @change="choseBlock(qu1,1)" placeholder="区级地区"><el-option v-for="item in qus" :key="item.value" :label="item.value" :value="item.value"></el-option></el-select>
                        <el-input v-model="dialogHospitalDetailList.addressDetail" style="margin-top: 5px;" type="textarea" :rows="2" placeholder="请输入详细地址"></el-input>
                    </div>
                </el-form-item>
            </el-form>

            <!-- 报单详情 -->
            <h3 class="dialog-plate-title"><span>报单经销商</span></h3>
            <el-table :data="hospitalDetailData.slice((currentPage-1)*pagesize,currentPage*pagesize)" stripe border :height="tableHeight-450" :header-cell-style="getRowClass">
                <el-table-column fixed type="index" label="*" sortable min-width="40"></el-table-column>
                <el-table-column prop="applyOfficeName" label="科室" sortable min-width="120"></el-table-column>
                <el-table-column prop="applyDealerName" label="报单经销商" sortable min-width="250"></el-table-column>
                <el-table-column prop="applyTime" label="报单时间" :formatter="formatTimestampToTime" sortable min-width="170"></el-table-column>
                <el-table-column prop="applyStatusDesc" label="审核结果" sortable min-width="110"></el-table-column>
                <el-table-column prop="auditUserName" label="审核人" sortable min-width="100"></el-table-column>
                <el-table-column prop="auditTime" label="审核时间" :formatter="formatTimestampToTime" sortable min-width="170"></el-table-column>
            </el-table>
            <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage" :page-sizes="[5,10, 15,20, 25,30,50, 100]" :page-size="pagesize" layout="total, sizes, prev, pager, next, jumper" :total="hospitalDetailData.length"></el-pagination>

        </el-dialog>



        <!-- 提示信息 -->
        <el-dialog title="提示信息" :visible.sync="dialogVisible" center width="300px">
            <span v-html="Promptinformation"></span>
            <span slot="footer" class="dialog-footer">
                <el-button @click="submitToExamineList">继续报单</el-button>
                <el-button type="primary" @click="dialogVisible = false">取消报单</el-button>
            </span>
        </el-dialog>



    </div>
</template>

<script>
    export default {
        name: "Intention",
        data() {
            let tokenId = sessionStorage.getItem("tokenId");
            return {

                // 三级联动
                addressData: {},
                shengs: '',
                shis: [],
                qus: [],
                city: '',
                block: '',

                tokenId: tokenId,
                currentPage: 1,
                pagesize: 10,
                activeName: '1',
                tableHeight: document.documentElement.clientHeight - 130,
                dataList: [],
                hospitalCategory: [],
                hospitalLevel: [],
                departments: [],

                // 详情框
                isDialog: false,
                dialogTitle: '',
                dialogHeight: {
                    height: document.documentElement.clientHeight - 230 + 'px',
                    minHeight: document.documentElement.clientHeight - 230 + 'px',
                    overflowY: 'auto',
                },
                dialogList: {
                    id: "",
                    applyHospitalId: "",//申请报单医院的ID
                    applyHospitalName: "",//申请报单的医院的名称
                    applyHospitalType: "",//报单医院的类型
                    applyHospitalTypeDesc: "",
                    applyHospitalLevel: "",//报单医院的级别
                    applyHospitalLevelDesc: "",
                    applyAddressSheng: "",//省
                    applyAddressShi: "",//市
                    applyAddressQuxian: "",//区县
                    applyAddressDetail: "",//详细
                    applyOffice: "",//申请报单科室
                    applyOfficeName: "",
                    applyDealerId: "",//申请经销商
                    applyDealerName: "",
                    applyDealerUserId: "",//申请人员
                    applyDealerUserName: "",
                    applyTime: "",//申请时间
                    applyReason: "",//申请原因
                    applyStatus: "",//申请状态
                    applyStatusDesc: "",
                    auditUserId: "",//审核人
                    auditUserName: "",
                    auditTime: "",//审核时间
                    auditDetail: "",//审核批注
                    revokeUserId: "",//撤销人
                    revokeUserName: "",
                    revokeTime: "",//撤销时间
                    revokeReason: "",//撤销缘由
                },
                isState:true,
                isToExamine:true,
                dialogDetailList: {
                    applyAddressDetail: "",
                    applyAddressQuxian: "",
                    applyAddressSheng: "",
                    applyAddressShi: "",
                    applyDealerId: "",
                    applyDealerName: "",
                    applyDealerUserId: "",
                    applyDealerUserName: "",
                    applyHospitalId: "",
                    applyHospitalLevel: "",
                    applyHospitalLevelDesc: "",
                    applyHospitalName: "",
                    applyHospitalType: "",
                    applyHospitalTypeDesc: "",
                    applyOffice: "",
                    applyOfficeName: "",
                    applyReason: "",
                    applyStatus: "",
                    applyStatusDesc: "",
                    applyTime: "",
                    auditDetail: "",
                    auditTime: "",
                    auditUserId: "",
                    auditUserName: "",
                    id: "",
                    revokeReason: "",
                    revokeTime: "",
                    revokeUserId: "",
                    revokeUserName: "",
                },
                sheng: '',
                shi: '',
                qu: '',

                dialogVisible:false,
                Promptinformation:'',

                //地图
                zoom: 10,
                center: [104.19025, 30.58958],
                markers: [],
                windows: [],
                groundimages: [],
                window: '',
                mapData: [],
                plugin: [{
                    pName: 'MapType',
                    defaultType: 0,
                    events: {
                        init(instance) {
                            console.log(instance);
                        }
                    }
                }],

                // 医院报单详情
                isHospitalDetailDialog:false,
                dialogHospitalDetailList:{
                    addressDetail: '',
                    addressQuxian: '',
                    addressSheng: '',
                    addressShi: '',
                    applyStatus: '',
                    dean: '',
                    directDept: '',
                    economicType: '',
                    establishDate: '',
                    hospitalJd: '',
                    hospitalLevel: '',
                    hospitalLevelDesc: '',
                    hospitalName: '',
                    hospitalTel: '',
                    hospitalTraining: '',
                    hospitalType: '',
                    hospitalTypeDesc: '',
                    hospitalWd: '',
                    id: '',
                    inputTime: '',
                    inputUnit: '',
                    inputUnitDesc: '',
                    inputUnitType: '',
                    inputUserId: '',
                    inputUserName: '',
                    medicalInsurancePoint: '',
                    nameEn: '',
                    operateNature: '',
                },
                sheng1: '',
                shi1: '',
                qu1: '',
                hospitalDetailData:[],
            }
        },
        created() {
            this.getData();
            this.getHospitalCategoryData();
            this.getHospitalLevelData();
            this.getAllCityData();
        },
        methods: {
            getHospitalCategoryData() {
                let _this = this;
                this.$http({
                    url: '/api/adscm/dealer/jyHospitalBase/getHospitalTypeLevel/1?tokenId=' + _this.tokenId,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                }).then(function (res) {
                    console.log(res.data)
                    if (res.data.statusCode == 200) {
                        _this.hospitalCategory = res.data.content;
                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                })

            },
            getHospitalLevelData() {
                let _this = this;
                this.$http({
                    url: '/api/adscm/dealer/jyHospitalBase/getHospitalTypeLevel/2?tokenId=' + _this.tokenId,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                }).then(function (res) {
                    console.log(res.data)
                    if (res.data.statusCode == 200) {
                        _this.hospitalLevel = res.data.content;
                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                })

            },
            getData() {
                let _this = this;
                let loading = this.$loading({
                    target: document.querySelector(".wrapper > .content-box"),
                    lock: true,
                    text: '正在努力加载中...',
                    spinner: 'el-icon-loading',
                    background: 'rgba(0, 0, 0, 0.8)'
                });
                this.$http({
                    url: '/api/adscm/dealer/jyDeclarationFormAudit/querySelfDecFormYix?tokenId=' + _this.tokenId,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                }).then(function (res) {

                    console.log(res.data)

                    if (res.data.statusCode == 200) {
                        _this.dataList = res.data.content;
                        loading.close();
                    } else {
                        _this.$message.error(res.data.desc);
                        loading.close();
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                    loading.close();
                })
            },
            getAllCityData() {
                let _this = this;
                this.$http.get('.././../static/json/map.json').then(function (response) {
                    if (response.status == 200) {
                        let data = response.data;
                        _this.addressData = response.data;
                        _this.shengs = [];
                        _this.city = [];
                        _this.block = [];
                        // 省市区数据分类
                        for (let item in data) {
                            if (item.match(/0000$/)) {//省
                                _this.shengs.push({id: item, value: data[item], children: []})
                            } else if (item.match(/00$/)) {//市
                                _this.city.push({id: item, value: data[item], children: []})
                            } else {//区
                                _this.block.push({id: item, value: data[item]});
                            }
                        }
                        // 分类市级
                        for (let index in _this.shengs) {
                            for (let index1 in _this.city) {
                                if (_this.shengs[index].id.slice(0, 2) === _this.city[index1].id.slice(0, 2)) {
                                    _this.shengs[index].children.push(_this.city[index1]);
                                }
                            }
                        }
                        // 分类区级
                        for (let item1 in _this.city) {
                            for (let item2 in _this.block) {
                                if (_this.block[item2].id.slice(0, 4) === _this.city[item1].id.slice(0, 4)) {
                                    _this.city[item1].children.push(_this.block[item2]);
                                }
                            }
                        }
                    } else {
                        console.log(response.status);
                    }
                }).catch(function (error) {
                    console.log(typeof +error)
                })
            },

            //基本信息
            updateList(row) {
                this.dialogList.id = row.id;
                this.dialogList.applyHospitalId = row.applyHospitalId;
                this.isState = row.applyHospitalId ? true :false;
                this.getDetailData();
                this.isDialog = true;
                this.activeName = "1";
                this.dialogTitle = '编辑';
            },
            getDetailData() {
                let _this = this;
                this.$http({
                    url: '/api/adscm/dealer/jyDeclarationForm/queryDealerApplyFormDetail/' + _this.dialogList.id + '?tokenId=' + _this.tokenId,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                }).then(function (res) {
                    console.log(res.data)
                    if (res.data.statusCode == 200) {
                        _this.dialogDetailList = res.data.content;
                        _this.dialogDetailList.applyHospitalLevel = _this.dialogDetailList.applyHospitalLevel + '';
                        _this.sheng = _this.dialogDetailList.applyAddressSheng;
                        _this.shi = _this.dialogDetailList.applyAddressShi;
                        _this.qu = _this.dialogDetailList.applyAddressQuxian;
                        _this.isToExamine = _this.dialogDetailList.applyStatus == '1' ? true : false;
                        _this.dialogDetailList.applyStatus = (_this.dialogDetailList.applyStatus != '1' || _this.dialogDetailList.applyStatus != '2') ? _this.dialogDetailList.applyStatusDesc : _this.dialogDetailList.applyStatus;
                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {})
            },
            submitList() {
                let _this = this;

                _this.dialogDetailList.applyAddressSheng = this.sheng;
                _this.dialogDetailList.applyAddressShi = this.shi;
                _this.dialogDetailList.applyAddressQuxian = this.qu;
                _this.dialogDetailList.applyTime = this.timestampToTime( _this.dialogDetailList.applyTime );
                _this.dialogDetailList.applyStatus = '0';


                console.log(_this.dialogDetailList)

                this.$http({
                    url: '/api/adscm/dealer/jyDeclarationFormAudit/confirmSaveHospital?tokenId='+_this.tokenId,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                    data: _this.dialogDetailList
                }).then(function (res) {
                    console.log(res.data)
                    if (res.data.statusCode == 200) {
                        _this.isDialog = false;
                        _this.getData();
                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                })

            },
            //审核

            isSubmitToExamineList(){
                let _this = this;
                this.$http({
                    url: "/api/adscm/dealer/jyDeclarationFormAudit/queryAuditFormStatus/"+_this.dialogDetailList.id+"?tokenId=" + _this.tokenId,
                    method: "post",
                    headers: {"X-Requested-With": "XMLHttpRequest"},
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.submitToExamineList();
                    } else if (res.data.statusCode == 300) {
                        _this.dialogVisible = true;
                        _this.Promptinformation = res.data.desc;
                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                });
            },

            submitToExamineList(){
                let _this = this;
                _this.dialogDetailList.auditTime = this.timestampToTime( _this.dialogDetailList.auditTime );
                let data = {
                    id:_this.dialogDetailList.id,
                    auditUserId:_this.dialogDetailList.auditUserId,
                    auditUserName:_this.dialogDetailList.auditUserName,
                    auditTime:_this.dialogDetailList.auditTime,
                    auditDetail:_this.dialogDetailList.auditDetail,
                    applyStatus:_this.dialogDetailList.applyStatus,
                    applyStatusDesc:_this.dialogDetailList.applyStatusDesc,
                };


                console.log(  data )

                this.$http({
                    url: '/api/adscm/dealer/jyDeclarationFormAudit/submitAudit?tokenId='+_this.tokenId,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                    data: data
                }).then(function (res) {
                    console.log(res.data)
                    if (res.data.statusCode == 200) {
                        _this.isDialog = false;
                        _this.getData();
                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                })


            },

            //地图
            getMapData() {
                let _this = this;
                this.$http({
                    url: '/api/adscm/dealer/jyDeclarationFormAudit/queryAllHospitalJwd/' + _this.dialogList.id + '?tokenId=' + _this.tokenId,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                }).then(function (res) {
                    console.log(res.data)
                    if (res.data.statusCode == 200) {
                        _this.mapData = res.data.content;
                        _this.drawMapChart();
                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                })
            },
            drawMapChart() {
                let self = this;
                let markers = [], windows = [];
                for (let j = 0; j < this.mapData.length; j++) {
                    let item = this.mapData[j];
                    if ( item.hospitalJd && item.hospitalWd ) {
                        markers.push({
                            position: [item.hospitalJd, item.hospitalWd],
                            applyStatus: item.applyStatus,
                            visible:true,
                            icon: (item.applyStatus == 0 ? '../../../../static/img/icon02.png' : (item.applyStatus == 1 ? '../../../../static/img/icon01.png' : (item.applyStatus == 2 ? '../../../../static/img/icon05.png' : ""))),
                            events: {
                                click() {
                                    self.windows.forEach(window => {window.visible = false;});
                                    self.window = self.windows[j];
                                    self.$nextTick(() => {
                                        //点击事件
                                        self.window.visible = false;
                                        self.dialogHospitalDetailList = item;
                                        self.dialogHospitalDetailList.hospitalLevel = item.hospitalLevel+'';
                                        self.isHospitalDetailDialog=true;
                                        self.sheng1=item.addressSheng;
                                        self.shi1=item.addressShi;
                                        self.qu1=item.addressQuxian;
                                        self.getHospitalDetailData(   self.dialogHospitalDetailList.id );
                                    });
                                }
                            }
                        });
                        windows.push({
                            position: [item.hospitalJd, item.hospitalWd],
                            content: `<div class="prompt"><p>医院名称：${item.hospitalName}</p><p>地址：${item.addressSheng}${item.addressShi}${item.addressQuxian}${item.addressDetail}</p><p>医院级别：${item.hospitalLevelDesc}</p><p>医院类型：${item.hospitalTypeDesc}</p></div>`,
                            visible: false,
                        });

                    }
                }
                this.markers = markers;
                this.windows = windows;
            },
            toggleVisible(idx) {

                let icon1 = '';
                let icon2 = '';
                let icon3 = '';
                let icon = '';

                for (let i = 0; i < this.markers.length; i++) {
                    let item = this.markers[i];
                    if (item.applyStatus == idx) {
                        let visableVar = this.markers[i].visible;
                        this.markers[i].visible = !visableVar;

                        console.log( idx )
                        if ( visableVar ) {
                            this.$refs['icon'+idx].src = icon;
                        } else {
                            if(idx==0){
                                this.$refs['icon'+idx].src = icon1;
                            } else if(idx==1){
                                this.$refs['icon'+idx].src = icon2;
                            } else if(idx==2){
                                this.$refs['icon'+idx].src = icon3;
                            }
                        }
                    }
                }
            },

            //医院报单详情
            getHospitalDetailData(id){

                console.log( id )

                let _this = this;
                if ( id ) {
                    this.$http({
                        url: '/api/adscm/dealer/jyDeclarationFormAudit/queryHospitalDeclarationFormDetail/' + id + '?tokenId=' + _this.tokenId,
                        method: 'post',
                        headers: {'X-Requested-With': 'XMLHttpRequest'},
                    }).then(function (res) {
                        console.log(res.data)
                        if (res.data.statusCode == 200) {
                            _this.hospitalDetailData = res.data.content;
                        } else {
                            _this.$message.error(res.data.desc);
                        }
                    }).catch(function (catchres) {
                        _this.$message.error("加载失败！请重新加载...");
                    })
                } else {
                    _this.$alert('请先确定当前医院信息', '提示', {confirmButtonText: '确定', callback: action => {
                            _this.isHospitalDetailDialog = false;
                            _this.isDialog = false;
                        }
                    });
                }
            },

            // 加载china地点数据，三级
            choseSheng: function (e, index) {
                for (let index2 in this.shengs) {
                    if (e === this.shengs[index2].value) {
                        this.shis = this.shengs[index2].children;
                        this['shi' + index] = this.shengs[index2].children[0].value;
                        this.qus = this.shengs[index2].children[0].children;
                        this['qu' + index] = this.shengs[index2].children[0].children[0].value;
                        this.E = this.qus[0].value;
                    }
                }
            },
            choseCity: function (e, index) {
                for (let index3 in this.city) {
                    if (e === this.city[index3].value) {
                        this.qus = this.city[index3].children;
                        this['qu' + index] = this.city[index3].children[0].value;
                        this.E = this.qus[0].value;
                    }
                }

            },
            choseBlock: function (e, index) {
                this.E = e;
            },


            handleSizeChange: function (size) {
                this.pagesize = size;
            },
            handleCurrentChange: function (currentPage) {
                this.currentPage = currentPage;
            },
            handleClick(tab, event) {
                this.pagesize=10;
                this.currentPage=1;
                if (tab.name === '2') {
                    this.getMapData();
                } else if (tab.name === '3') {
                    this.getHospitalDetailData(this.dialogList.applyHospitalId);
                }
            },
            formatTimestampToTime(row, column, cellValue, index) {
                return cellValue ? this.timestampToTime(cellValue) : '';
            },
            timestampToTime(timestamp) {
                if (timestamp) {
                    let date = new Date(timestamp);
                    let Y = date.getFullYear() + '-';
                    let M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
                    let D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + " ";
                    let h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ":";
                    let m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ":";
                    let s = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds();
                    return timestamp ? Y + M + D + h + m + s : '';
                } else {
                    return '';
                }
            },
        }
    }
</script>

<style scoped>


</style>
